<!doctype html>
<html>
<head>
    <meta charset="UTF-8" />
    <title>商品详情</title>
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=0" />
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="format-detection" content="telephone=no">
    <link rel="stylesheet" type="text/css" href="__PUBLIC__/Wx/css/base.css"/>
    <link rel="stylesheet" type="text/css" href="__PUBLIC__/Wx/css/detail.css"/>
</head>
<body>
<div class="prodetail">
    <div class="swipePanel">
        <div class="swipe">
            <!--<?php  dump(￥)?>-->
            <ul id="slider">
                <volist name="info.h_imgs" id="vo">
                    <li><a href="javascript:void(0)"><img src="{$vo}" alt='' /></a></li>
                </volist>
            </ul>
            <div id="pagenavi">
                <volist name="info.h_imgs" id="vo">
                    <a href="javascript:void(0);" class="active">{$key+1}</a>
                </volist>

            </div>
        </div>
    </div>
    <div class="proname">
        <h2><b class="xc">乡村</b><span><?=msubstr($info['title'],40)?> {$info.u_num}{$info.p_unit}</span></h2>
        <h4><span><del>原价：￥{$info.price}</del></span><span>已售<b>1000</b>份</span><span>库存<b class="info_num">{$info.num}</b>份</span></h4>
    </div>
    <div class="price" style="margin-top:10px;">
        <i>批发价</i>
        <p>
            <volist name="info['price_range']" id="v">
                <span><b>￥{$v.price}</b><em>{$v.start}-{$v.end}件</em></span>
            </volist>
        </p>
    </div>
    <div class="place">
        <p>产地<span style="color:#333;">{$farm.a1}{$farm.a2}{$farm.a3}{$farm.a4}{$farm.a5}{$farm.village}</span></p>
        <p>责任农户<span style="color:#333;"><img src="{$u_info.avatar}"/><i>{$u_info.realname}</i></span></p>
    </div>

    <div class="propic">
        <h2>商品详情</h2>
        <div class="intro">
            {$info.content}
        </div>
    </div>
    <div class="bot bot02">
        <a href="group.html">我的社区</a>
        <span class="sc">收藏</span>
        <a href="__MODULE__/Wholesale/cart" class="cart02">购物车<b class="shopping_num">{$info.wholesale}</b></a><i style="line-height:50px;" class="pay">立即批发</i><i style="line-height:50px;" class="shopping">加入购物车</i>
    </div>
    <div class="ComfirmBox" id="ComfirmBox">
        <div class="ProProp">
            <div class="LineList">
                <div class="ProPic"><img src="{$info['h_imgs'][0]}" /></div>
                <div class="nameContent">
                    <div class="proprice"><span>&yen;{$info['price_range']['0']['price']}</span></div>
                    <div class="count">请选择商品数量和规格</div>
                </div>
                <div class="size">
                    <h2>规格</h2>
                    <span>{$info.u_num}{$info.p_unit}</span>
                    <!--<span>10斤</span>-->
                    <!--<span>15斤</span>-->
                </div>
                <div class="price">
                    <i>批发价</i><p class="price_range">
                    <volist name="info['price_range']" id="v">
                        <span><b>￥{$v.price}</b><em>{$v.start}-{$v.end}件</em></span>
                    </volist>
                </p>
                </div>
                <dl class="NumLine">
                    <dt>数量</dt>
                    <dd>
                        <div class="reduce" onClick="ChangeNumber(-1)">-</div>
                        <div class="Number"><input type="text" id="Number" value="{$info.number_pf}"/></div>
                        <div class="Add" onClick="ChangeNumber(1)">+</div>
                    </dd>
                </dl>
            </div>
            <div class="Action pay" style="display: none"><input type="button" value="确定" onClick="payorder()"/></div>
            <div class="Action shopping" style="display: none"><input type="button" value="确定" onClick="shoppingorder()"/></div>
            <div class="del"></div>
        </div>
    </div>
</div>
<script type="text/javascript" src="__PUBLIC__/Wx/js/touchScroll.js"></script>
<script type="text/javascript" src="__PUBLIC__/Wx/js/touchslider.js"></script>
<script type="text/javascript">
    var active = 0, as = document.getElementById('pagenavi').getElementsByTagName('a');
    for ( var i = 0; i < as.length; i++) {
        (function() {
            var j = i;
            as[i].onclick = function() {
                t.slide(j);
                return false;
            };
        })();
    }
    var t = new TouchSlider({
        id : 'slider',
        speed : 600,
        timeout : 2000,
        before : function(index) {
            as[active].className = '';
            active = index;
            as[active].className = 'active';
        }
    });
</script>
<!--引用悬浮公共导航文件-->
<include file="Public:nav" />
<script type="text/javascript" src="__PUBLIC__/Wx/js/jquery-1.9.1.js"></script>
<script type="text/javascript">

    $(".click span").click(function(){
        if($(this).text() ==="导航"){
            $(this).text("收起");
            $('.link02').css('display','block')
        }else{
            $(this).text("导航");
            $('.link02').css('display','none')
        }//end if
    });//end fun

    $('.bot i.pay').click(function(){
        $('.ComfirmBox').css('display','block');
        $(".Action.shopping").css('display','none');
        $(".Action.pay").css('display','block');

    });
    $('.bot i.shopping').click(function(){
        $('.ComfirmBox').css('display','block');
        $(".Action.pay").css('display','none');
        $(".Action.shopping").css('display','block')
    });
    // $('.size span').click(function(){
    //     $(this).addClass("on").siblings().removeClass()
    // });
    $('.del').click(function(){
        $('.ComfirmBox').css('display','none')
    });
    function payorder() {
        var number = document.getElementById("Number").value;
        var gid = "{$info['id']}";
        $.post('__MODULE__/Wholesale/addshopping',{'number':number,'gid':gid,'op':'payorder'},function (d) {
            if(d.state == 2){
                window.location.href="__MODULE__/Wholesale/Payment/wid/"+d.wid;
            }else{
                $('.ComfirmBox').css('display','none');
                if (d.val){
                    alert(d.val);
                }//end if
            }//end if

        });//end post
    }//end fun

    function shoppingorder() {
        var number = document.getElementById("Number").value;
        var gid = "{$info['id']}";
        $.post('__MODULE__/Wholesale/addshopping',{'number':number,'gid':gid,'op':'shoppingorder'},function (d) {
            if(d.state >0){
                $('.ComfirmBox').css('display','none');
            }else{
                $('.ComfirmBox').css('display','none');
                $(".shopping_num").text(d.num);
            }//end if
            if (d.val){
                alert(d.val);
            }//end if
        });//end post
    }//end fun

    function ChangeNumber(val){
        var this_val = val;
        var count_number = $("#Number").val();
        if(this_val == 1){
            count_number++;
        }else{
            count_number--;
        }//end if
        var gid = parseInt("{$info.id}");
        // console.log(price_range)
        $.post("__MODULE__/Wholesale/reloadcart",{'gid':gid,'number':count_number,'this_val':this_val},function (d) {
                if (d.val){
                    $(".info_num").text(parseInt(d.num));
                    alert(d.val);
                }else{
                    $("#Number").val(d.number);
                    $(".proprice").children("span").text("￥"+d.price);
                }//end if
        });//end post
    }//end fun
</script>
</body>
</html>